package MyQueue;

import java.util.List;

public class MyQueue {


    public static class ListNode{
        ListNode prv;
        ListNode next;
        int val;

        public ListNode(int val) {
            this.val = val;
        }
    }

    public ListNode head=null;
    public ListNode tail=null;
    public int size=0;

    public void offer(int val){
        ListNode node=new ListNode(val);
        if(head==null){
            head=node;
            tail=node;
        }else {
            tail.next=node;
            node.prv=tail;
            tail=tail.next;
        }
        size++;
    }

    public int poll(){
        if(head==null){
            return -1;
        }else {
           int x= head.val;
            head=head.next;
            if(head!=null){
                head.prv=null;
            }
            size--;
            return x;
        }
    }

    public int peek(){
        if (head==null){
            return -1;
        }else {
            return head.val;
        }
    }

public boolean isempty(){
        return size==0;
}
}
